<?php echo $form->hiddenField($model, "id") ; ?>
<?php echo $form->hiddenField($model, "page_id") ; ?>

<div class="row">
    <?php echo $form->labelEx($model,'template_content_id', array('label'=>'Template')); ?>  
    <?php $this->widget('Cms.widgets.TemplateContentDropDownList', array(
        'model'=>$model,
        'attribute'=>'template_content_id',
        'htmlOptions'=>array('class'=>'template-options', 'prompt'=>'---Select---'),
    ));
    ?>
    <?php echo $form->error($model, 'template_content_id'); ?>
</div>

<div class="row">
    <label>&nbsp;</label>Please note that choosing a new template might requires you to choose suitable JS, CSS
</div>

<div class="row">
    <?php echo $form->labelEx($model, 'css_files'); ?>
    <?php if (count($model->css_files) < 0 || empty($model->css_files[0]) === true):?>
    Using template CSS files. You can override template CSS with Page's CSS<br/>
    <?php echo CHtml::link('Copy all CSS from template', array(
        '/Core/service/ajax', 
        'SID'=>'Cms.pageRevision.copyFromTemplate',
        'page_id'=>$model->page_id,
        'revision_id'=>$model->id,
    ), array('class'=>'copy-css'));?>
    <?php endif;?>
</div>

<div class="files">
<?php foreach ($model->css_files as $index => $value):?>
<div class="row">
    <label>&nbsp;</label>
    <div class="actions">
    <?php $this->widget('Admin.components.FileWidget', array(
        'name'=>CHtml::resolveName($model, $attribute='css_files').'[]',
        'value'=>$value,
        'root'=>'/themes/'.Yii::app()->cmsManager->CmsTheme->name.'/styles/',
        'showButtonRemove'=>false,
    )); ?>
        <a href="#" onclick="return jQuery.remove(this)" title="Remove" class="remove">Remove</a>
        <a href="#" onclick="return jQuery.duplicate(this)" title="Add" class="add">Add</a>
    </div>
</div>
<?php endforeach;?>
</div>

<div class="row">
    <?php echo $form->labelEx($model, 'js_files'); ?>
    <?php if (count($model->js_files) < 0 || empty($model->js_files[0]) === true):?>
    Using template JS files. You can override template JS with Page's JS<br/>
    <?php echo CHtml::link('Copy all JS from template', array(
        '/Core/service/ajax', 
        'SID'=>'Cms.pageRevision.copyFromTemplate',
        'page_id'=>$model->page_id,
        'revision_id'=>$model->id,
    ), array('class'=>'copy-js'));?>
    <?php endif;?>
</div>

<div class="files">
<?php foreach ($model->js_files as $index => $value):?>
<div class="row">
    <label>&nbsp;</label>
    <div class="actions">
    <?php $this->widget('Admin.components.FileWidget', array(
        'name'=>CHtml::resolveName($model, $attribute='js_files').'[]',
        'value'=>$value,
        'root'=>'/themes/'.Yii::app()->cmsManager->CmsTheme->name.'/scripts/',
        'showButtonRemove'=>false,
    )); ?>
        <a href="#" onclick="return jQuery.remove(this)" title="Remove" class="remove">Remove</a>
        <a href="#" onclick="return jQuery.duplicate(this)" title="Add" class="add">Add</a>
    </div>
</div>
<?php endforeach;?>
</div>
